package com.cxs.task.plus;

import com.cxs.service.ScheduledTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @Project: scheduled-demo
 * @Author: cxs2014501@163.com
 * @Create: 2023/1/16 15:45
 * @Description: 这个类会在Spring容器启动时加载所有需要启动的任务并开始执行
 **/
@Slf4j
@Component
public class ScheduledTaskRunner implements ApplicationRunner {

    @Autowired
    private ScheduledTaskService scheduledTaskService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        // 初始化所有任务
        scheduledTaskService.initAllTask();
    }
}
